<?php

/**
 * Handling directory and file list.
 * @package Util
 * @author nullstring
 */
class DirectoryHandler
{
    /**
     * Returns with files in direcotry
     * @param string $directory
     * @return array
     */
	static public function getFiles($directory)
	{
        setType($directory, "string");
        
		$files = array();

		if (($dh = opendir($directory)) !== false) {
		    while (false !== ($file = readdir($dh))) {
		    	if (is_file($directory . "/" . $file)) {
		    		$files[] = $file;
		    	}
		    }
		}

		return $files;
	}

    /**
     * Returns with direcoties in directory
     * @param string $directory
     * @return array
     */
	static public function getDirs($directory)
	{
        setType($directory, "string");
        
		$files = array();

		$nonDirs = array(
			".", ".."
		);

		if (($dh = opendir($directory)) !== false) {
		    while (false !== ($file = readdir($dh))) {
		    	if (is_dir($directory . "/" . $file) && !in_array($file, $nonDirs)) {
		    		$files[] = $file;
		    	}
		    }
		}

		return $files;
	}
}

?>